#include "GBuffer.h"

#include "IRenderDevice.h"

namespace Rz { namespace Graphics { namespace Render {

GBuffer::GBuffer(IRenderDevice* renderDevice, const Math::Size& size)
	: _size(size)
{
	this->SetRenderDevice(renderDevice);

	_color		= renderDevice->CreateRenderTarget2D(size, SurfaceFormat::Color,  DepthFormat::None);
	_normal		= renderDevice->CreateRenderTarget2D(size, SurfaceFormat::Color,  DepthFormat::None);
	_depth		= renderDevice->CreateRenderTarget2D(size, SurfaceFormat::Single, DepthFormat::Depth24);

	_gshader	= renderDevice->CreateEffect("GBuffer");
}

const IRenderTarget2D* GBuffer::GetColorBuffer() const
{
	return _color;
}

IRenderTarget2D* GBuffer::GetColorBuffer()
{
	return _color;
}

const IRenderTarget2D* GBuffer::GetNormalBuffer() const
{
	return _normal;
}

IRenderTarget2D* GBuffer::GetNormalBuffer()
{
	return _normal;
}

const IRenderTarget2D* GBuffer::GetDepthBuffer() const
{
	return _depth;
}

IRenderTarget2D* GBuffer::GetDepthBuffer()
{
	return _depth;
}

const IEffect* GBuffer::GetShader() const
{
	return _gshader;
}

IEffect* GBuffer::GetShader()
{
	return _gshader;
}

} } }
